package com.gpframework.module.base.domain.req;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author BrinedFish
 * @create 2022-04-12 11:23
 */
@Data
public class BrandBaseEntity {

    /**
     * 部门用户idList
     */
    @ApiModelProperty(value = "部门用户idList")
    private List<Long> salesmanIdList;

    /**
     * 创建人idList
     */
    @ApiModelProperty(value = "创建人idList")
    private List<Long> createByList;

    /**
     * 门店idList
     */
    @ApiModelProperty(value = "门店idList")
    private List<Long> storeIdList = new ArrayList<>();

    /**
     * 部门用户idList
     */
    @ApiModelProperty(value = "部门用户idList")
    private List<Long> deptUserList = new ArrayList<>();

    /**
     * 当前用户的微信用户id
     */
    private Long loginWxUserId;

    /**
     * 当前用户的微信名称
     */
    private String loginWxUserName;

    /**
     * 数据范围过滤
     */
    private String roleDataScope;

    public void setSalesmanIdList(List<Long> salesmanIdList) {
        this.salesmanIdList = salesmanIdList;
    }

    public void setSalesmanIdList(String salesmanIdStr) {
        if (StringUtils.isEmpty(salesmanIdStr)) {
            this.salesmanIdList = null;
            return;
        }
        String[] split = salesmanIdStr.split(",");
        this.salesmanIdList = new ArrayList<>();
        for (String id : split) {
            this.salesmanIdList.add(Long.parseLong(id));
        }
    }

    public void setCreateByList(List<Long> createByList) {
        this.createByList = createByList;
    }

    public void setCreateByList(String createByStr) {
        if (StringUtils.isEmpty(createByStr)) {
            this.createByList = null;
            return;
        }
        String[] split = createByStr.split(",");
        this.createByList = new ArrayList<>();
        for (String id : split) {
            this.createByList.add(Long.parseLong(id));
        }
    }

    public void setStoreIdList(List<Long> storeIdList) {
        this.storeIdList = storeIdList;
    }

    public void setStoreIdList(String storeIdList) {
        if (StringUtils.isEmpty(storeIdList)) {
            this.storeIdList = null;
            return;
        }
        String[] split = storeIdList.split(",");

        for (String id : split) {
            this.storeIdList.add(Long.parseLong(id));
        }
    }

    public List<Long> getDeptUserList() {
        return deptUserList;
    }

    public void setDeptUserList(List<Long> deptUserList) {
        this.deptUserList = deptUserList;
    }

    public void setDeptUserList(String deptUserListStr) {
        if (StringUtils.isEmpty(deptUserListStr)) {
            this.deptUserList = null;
            return;
        }
        String[] split = deptUserListStr.split(",");
        this.deptUserList = new ArrayList<>();
        for (String id : split) {
            this.deptUserList.add(Long.parseLong(id));
        }
    }
}
